package com.example.controller.seller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.base.ResultBaseController;
import com.example.entity.Order;
import com.example.entity.OrderEvaluation;
import com.example.entity.User;
import com.example.param.SearchAndOrder;
import com.example.service.OrderEvaluationService;
import com.example.service.UserService;
import com.example.vo.IdHolder;
import com.example.vo.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;

/**
 * @Description:
 * @Author: aimi
 * @Create: 2024-06-10
 **/
@RestController
@RequestMapping("/seller/evaluation")
public class SellerEvaluationController extends ResultBaseController<OrderEvaluationService, OrderEvaluation> {
    @Resource
    private UserService userService;

    @PostMapping("/page/{page}/{size}")
    @Override
    public Result<IPage<OrderEvaluation>> page(@PathVariable("page") int page, @PathVariable("size") int size, @RequestBody(required = false) SearchAndOrder<OrderEvaluation> searchAndOrder) {
        User user = userService.getById(IdHolder.getUserId());
        if(user.getHaveStore() == null || !user.getHaveStore()){
            return null;
        }
        OrderEvaluation orderEvaluation = searchAndOrder.getSearch();
        orderEvaluation.setStoreId(user.getStoreId());
        return super.page(page,size,searchAndOrder);
    }
}